import {timer} from '@/utils'
import {BsHouse} from 'react-icons/bs'

import './index.less'
import {history} from 'umi'

function CommentItem(props) {
  return (
    <div className='comment-item' onClick={()=>{props.handleClick && props.handleClick(props?.comment?.id)}}>
      <div className='header'>
        <img onClick={(e) => {
          e.stopPropagation()
          history.push({pathname: '/user/userDetail', query: {id: props?.comment?.uid}})
        }} src={props?.comment?.userUserInfoAvatar || require('@/assets/user.png')}/>
        <p className='name'>{props?.comment?.userNickName}</p>
        <p className='createdAt'>{timer(props.comment?.createdAt)}</p>
      </div>
      <p className='title'>{props?.comment?.title}</p>
      <p className='content'>{props?.comment?.content}</p>
      <div className='pictures'>
        {props?.comment?.pictures && props.comment?.pictures.split('|').map(item => (
          <img src={item} key={item}/>
        ))}
      </div>
      {props?.comment?.houseAddress&&<p className='houseAddress'><BsHouse style={{marginRight:'6px',color:'#0482FF'}} />{props?.comment?.houseAddress}</p>}
    </div>
  )
}

export default CommentItem
